package cn.ycl.system.biz.service.service.impl;

import cn.ycl.system.biz.service.dao.ProductServiceDao;
import cn.ycl.system.biz.service.entity.ProductService;
import cn.ycl.system.biz.service.service.ProductServiceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ProductService)表服务实现类
 *
 * @author yuanchangliang
 * @since 2021-09-30 16:46:53
 */
@Service("productServiceService")
public class ProductServiceServiceImpl implements ProductServiceService {
    @Resource
    private ProductServiceDao productServiceDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public ProductService queryById(Long id) {
        return this.productServiceDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ProductService> queryAllByLimit(int offset, int limit) {
        return this.productServiceDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param productService 实例对象
     * @return 实例对象
     */
    @Override
    public ProductService insert(ProductService productService) {
        this.productServiceDao.insert(productService);
        return productService;
    }

    /**
     * 修改数据
     *
     * @param productService 实例对象
     * @return 实例对象
     */
    @Override
    public ProductService update(ProductService productService) {
        this.productServiceDao.update(productService);
        return this.queryById(productService.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.productServiceDao.deleteById(id) > 0;
    }
}
